<?php
/**
 * Created by PhpStorm.
 * User: chen
 * Date: 2016/10/9
 * Time: 10:01
 */
namespace app\home\controller;
use app\common\controller\HomeBase;
use app\common\model\Weibo;
use think\Session;

class Keep extends HomeBase{
    public function index () {
        $data = db('Keep')->where(['uid'=>Session::get('uid')])->field('wid')->select();
        $wids=[];
        if ($data) {
            foreach ($data as $v) {
                $wids[] = $v['wid'];
            }
        }
        //sql in () 为空时会报SQL执行错误
        if (!$wids) {
            $wids[] = 0;
        }
        $weibo = new Weibo();
        return $this->fetch('index',['data'=>$weibo->getListData(['w.id'=>['in',$wids]])]);
    }
}